package com.hzqy.persistence.dao.content;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.hzqy.web.vo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.hzqy.persistence.dao.core.PersistenceDao;
import com.hzqy.web.vo.content.CmContentLedgerVo;

@Repository
public class ContentDao extends PersistenceDao<CmContentVo, Integer>{
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	public int findContentCount(CmContentVo cmContentVo) {
		String namespace = this.getNamespace();
		return getSqlSession().selectOne(namespace + "findContentCount", cmContentVo);
	}
	
	public int findSeriesCount(CmSeriesVo cmSeriesVo) {
		String namespace = this.getNamespace();
		return getSqlSession().selectOne(namespace + "findSeriesCount", cmSeriesVo);
	}
	
	public List<CmContentVo> findContentList(Map<String,Object> map){
		String namespace = this.getNamespace();
		return getSqlSession().selectList(namespace + "findContentList", map);
	}
	
	public List<CmSeriesVo> findSeriesList(Map<String,Object> map) {
		String namespace = this.getNamespace();
		return getSqlSession().selectList(namespace + "findSeriesList", map);
	}
	
	public int deleteContent(int f_cc_id) {
		String namespace = this.getNamespace();
		return getSqlSession().update(namespace + "deleteContent", f_cc_id);
	}
	
	public int deleteContentOrg(int f_cc_id) {
		String namespace = this.getNamespace();
		return getSqlSession().delete(namespace + "deleteContentOrg", f_cc_id);
	}
	
	public int insertContentOrg(int f_cc_id,String f_cco_orgId) {
		String namespace = this.getNamespace();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("f_cc_id", f_cc_id);
		map.put("f_cco_orgId", f_cco_orgId);
		return getSqlSession().insert(namespace + "insertContentOrg", map);
	}
	
	public int deleteSeries(int f_ssc_status,String f_ssc_ids) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("f_ssc_status", f_ssc_status);
		map.put("f_ssc_ids", f_ssc_ids);
		return getSqlSession().update(this.getNamespace() + "deleteSeries" , map);
	}
	
	public int insertContent(CmContentVo contentVo) {
		return getSqlSession().insert(this.getNamespace() + "insertContent", contentVo);
	}


	public int insertSeries(CmSeriesVo cmSeriesVo) {
		return getSqlSession().insert(this.getNamespace() + "insertSeries", cmSeriesVo);
	}
	
	public int updateContent(CmContentVo contentVo) {
		return getSqlSession().update(this.getNamespace() + "updateContent", contentVo);
	}
	
	public int reviewContent(CmContentVo cmContentVo) {
		return getSqlSession().update(this.getNamespace() + "reviewContent",cmContentVo);
	}
	
	public int updateSeries(CmSeriesVo cmSeriesVo) {
		return getSqlSession().update(this.getNamespace() + "updateSeries", cmSeriesVo);
	}
	
	public CmContentVo selectContent(int f_cc_id) {
		return getSqlSession().selectOne(this.getNamespace() + "selectContent", f_cc_id);
	}
	
	public CmSeriesVo selectSeries(int f_ssc_id) {
		return getSqlSession().selectOne(this.getNamespace() + "selectSeries", f_ssc_id);
	}
	
	public List<CmContentVo> selectBindContent(Map<String,Object> map) {
		return getSqlSession().selectList(this.getNamespace() + "selectBindContent", map);
	}
	
	public List<CmContentVo> selectUnBindContent(Map<String,Object> map) {
		return getSqlSession().selectList(this.getNamespace() + "selectUnBindContent", map);
	}
	
	public int findBindCount(Map<String,Object> map) {
		return getSqlSession().selectOne(this.getNamespace() + "findBindCount",map);
	}
	
	public int findUnBindCount(Map<String,Object> map) {
		return getSqlSession().selectOne(this.getNamespace() + "findUnBindCount",map);
	}
	
	public int insertBind(CmCatalogContentVo cmCatalogContentVo) {
		return getSqlSession().insert(this.getNamespace() + "insertBind", cmCatalogContentVo);
	}
	
	public int deleteBind(CmCatalogContentVo cmCatalogContentVo) {
		return getSqlSession().delete(this.getNamespace() + "deleteBind", cmCatalogContentVo);
	}
	
	public List<CmCatalogVo> selectContentBindCatalog(int f_cc_id) {
		return getSqlSession().selectList(this.getNamespace() + "selectContentBindCatalog", f_cc_id);
	}
	
	public List<CmCatalogContentVo> selectCatalogBind(int f_ccc_contentid) {
		return getSqlSession().selectList(this.getNamespace() + "selectCatalogBind",f_ccc_contentid);
	}
	
	public List<CmContentOrgVo> selectOrgBind(int f_cco_contentId) {
		return getSqlSession().selectList(this.getNamespace() + "selectOrgBind",f_cco_contentId);
	}
	
	public CmCatalogContentVo selectViewIndex(CmCatalogContentVo cmCatalogContentVo) {
		return getSqlSession().selectOne(this.getNamespace() + "selectViewIndex", cmCatalogContentVo);
	}
	
	public int updateViewIndex(CmCatalogContentVo cmCatalogContentVo) {
		return getSqlSession().update(this.getNamespace() + "updateViewIndex", cmCatalogContentVo);
	}
	
	public List<Integer> selectUserCatalogList(String orgIds) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("orgIds", orgIds);
		return getSqlSession().selectList(this.getNamespace() + "selectUserCatalogList", map);
	}
	
	public int updateSeriseCount(CmContentVo contentVo) {
		return getSqlSession().update(this.getNamespace() + "updateSeriseCount", contentVo);
	}

	public int updateBatchCount(CmContentVo contentVo) {
		return getSqlSession().update(this.getNamespace() + "updateBatchCount", contentVo);
	}
	
	public int selectSeriesCount(int f_ssc_contentid) {
		return getSqlSession().selectOne(this.getNamespace() + "selectSeriesCount",f_ssc_contentid);
	}

	public int insertContentCast(CmContentCastVo cmContentCastVo) {
		return getSqlSession().insert(this.getNamespace() + "insertContentCast",cmContentCastVo);
	}
	
	public List<CmContentCastVo> selectContentCastBind(int f_ccast_contentid) {
		return getSqlSession().selectList(this.getNamespace() + "selectContentCastBind",f_ccast_contentid);
	}
	
	public int deleteCastBind(int f_ccast_contentid) {
		return getSqlSession().delete(this.getNamespace() + "deleteCastBind", f_ccast_contentid);
	}
	
	public int updateContentStatus(int f_cc_id,int f_cc_status) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("f_cc_id", f_cc_id);
		map.put("f_cc_status", f_cc_status);
		return getSqlSession().update(this.getNamespace() + "updateContentStatus", map);
	}

	public int updateContentCode(int f_cc_id, String f_cc_code) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("f_cc_id", f_cc_id);
		map.put("f_cc_code", f_cc_code);
		return getSqlSession().update(this.getNamespace() + "updateContentCode", map);
	}

	public List<PmsOrgVo> selectOrgListByModelId(Map<String, Object> map) {
		return getSqlSession().selectList(this.getNamespace() + "selectOrgListByModelId",map);
	}

	public Integer selectOrgListByModelIdCount(PmsOrgVo orgVo) {
		return getSqlSession().selectOne(this.getNamespace() + "selectOrgListByModelIdCount",orgVo);
	}

	public int insertCmContentLadger(CmContentLedgerVo cmContentLedger) {
		return getSqlSession().insert(this.getNamespace() + "insertCmContentLadger", cmContentLedger);
	}

	public List<CmContentVo> selectVoteContent(Map<String, Object> map) {
		return getSqlSession().selectList(this.getNamespace() + "selectVoteContent", map);
	}

	public Integer findVoteCount(Map<String, Object> map) {
		return getSqlSession().selectOne(this.getNamespace() + "findVoteCount",map);
	}

	public List<AcVoteUserLikeVo> selectVoteUser(Map<String, Object> map) {
		return getSqlSession().selectList(this.getNamespace() + "selectVoteUser",map);
	}
	public Integer finVoteUserCount(Map<String, Object> map) {
		return getSqlSession().selectOne(this.getNamespace() + "finVoteUserCount",map);
	}
	
	public CmVoteTotalVo selectVotaByContenId(Map<String, Object> map) {
		return getSqlSession().selectOne(this.getNamespace() + "selectVotaByContenId",map);
	}

	public int updateVote(Map<String, Object> map) {
		return getSqlSession().update(this.getNamespace() + "updateVote",map);
	}

	public int insertVoteUser(AcVoteUserLikeVo acVoteUserLikeVo) {
		return getSqlSession().insert(this.getNamespace() + "insertVoteUser", acVoteUserLikeVo);
	}

	public int insertVote(CmVoteTotalVo CmVoteTotalVo) {
		return getSqlSession().insert(this.getNamespace() + "insertVote", CmVoteTotalVo);
	}

	public Integer findVoteCountIn(Map<String, Object> map) {
		return getSqlSession().selectOne(this.getNamespace() + "findVoteCountIn",map);
	}

	public List<CmContentVo> selectVoteContentIn(Map<String, Object> map) {
		return getSqlSession().selectList(this.getNamespace() + "selectVoteContentIn", map);
	}
	
	public int deleteContentProduct(int f_cc_id) {
		String namespace = this.getNamespace();
		return getSqlSession().delete(namespace + "deleteContentProduct", f_cc_id);
	}
	
	public int insertContentProduct(int f_cc_id,String f_cco_orgId) {
		String namespace = this.getNamespace();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("f_ccp_contentId", f_cc_id);
		map.put("f_ccp_productId", f_cco_orgId);
		return getSqlSession().insert(namespace + "insertContentProduct", map);
	}
	
	public List<CmContentProductVo> selectProductBind(int f_ccp_contentId) {
		return getSqlSession().selectList(this.getNamespace() + "selectProductBind",f_ccp_contentId);
	}

	public int updateSdStatusHistory(Map<String,Object> map){
		return getSqlSession().update(this.getNamespace()+"updateSdStatusHistory",map);
	}
}
